package com.ruoyi.system.service.evaluationService.evaluationServiceImpl;

import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.evaluation.Complaint;
import com.ruoyi.system.domain.evaluation.ComplaintandStore;
import com.ruoyi.system.domain.evaluation.StoreLocation;
import com.ruoyi.system.mapper.evaluation.ComplaintMapper;
import com.ruoyi.system.service.evaluationService.ComplaintService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ComplaintServiceImpl implements ComplaintService {
    @Autowired
    private ComplaintMapper complaintMapper;
    @Override
    public List<Complaint> selectComplaint() {
        return complaintMapper.selectComplaint();
    }

    @Override
    public List<ComplaintandStore> selectComplaintandStore() {
        return complaintMapper.selectComplaintandStore();
    }

    @Override
    public List<ComplaintandStore> selectComplaintByIds(String ids) {
        Long[] complaintIds = Convert.toLongArray(ids);
        return complaintMapper.selectComplaintByIds(complaintIds);
    }

    @Override
    public int deleteComplaint(String ids) {
        Long[] complaintids = Convert.toLongArray(ids);
        return complaintMapper.deleteComplaint(complaintids);
    }

    @Override
    public List<ComplaintandStore> selectComplaintList(String storeName,String location_id) {
        String flag = storeName +location_id ;
        List<ComplaintandStore> list =null;
        if (StringUtils.isEmpty(flag)){
            list = complaintMapper.selectComplaintandStore();
        }else if (StringUtils.isNotEmpty(storeName)){
            list = complaintMapper.selectStoreByStoreName(storeName);
        }else if (StringUtils.isNotEmpty(location_id)){
            list = complaintMapper.selectComplaintByLocation_id(location_id);
        }else{
            list = complaintMapper.selectComplaintandStore();
        }
        return list;
    }

}

